<?php
/**
 * Created by PhpStorm.
 * User: keke
 * Date: 2020/8/14
 * Time: 18:51
 */
namespace App\Model;

use Illuminate\Support\Facades\DB;

class FinanceRoomSupportItem extends BaseModel
{
    protected $table = 'finance_room_support_item';

    public function getSupportItemList($request, $supportId)
    {
        $limit = $request->input('limit', 10);
        $page = $request->input('page', 1);

        return DB::connection($this->connection)->table('finance_room_support_item')
            ->where('support_id', '=', $supportId)
            ->orderBy('id','desc')
            ->paginate($limit,'*','page',$page);
    }

    public function financeRoomSupport(){
        return $this->belongsTo(FinanceRoomSupport::class,'id','id');
    }


    public function createSupportItem($data)
    {
        return curl_request(getKkaudioApiUrl() . '/inner/finance/settle/createFinanceRoomSupportItem', $data, 'urlencoded', 'POST');
    }

    public function updateSupportItem($data)
    {
        return curl_request(getKkaudioApiUrl() . '/inner/finance/settle/updateFinanceRoomSupportItem', $data, 'urlencoded', 'POST');
    }

    public function deleteSupportItem($data)
    {
        return curl_request(getKkaudioApiUrl() . '/inner/finance/settle/deleteFinanceRoomSupportItem', $data, 'urlencoded', 'POST');
    }
}